<template>
	<form @submit="bindFormSubmit">
	<view class="ca-page">
		<view class="form">
			<view class="form-row">
				<view class="title">支付金额</view>
				<input type="digit" name="amount" maxlength="10" @input="inputAmount" v-model:value="dataAmount" placeholder="请输入支付金额"/>
				<text>元</text>
			</view>
			<view class="form-row btn-row">
				<button form-type="submit">提交数据</button>
			</view>
		</view>
	</view>
	</form>
</template>

<script>
	const APP = getApp();
	
	export default {
		data() {
			return {
				dataAmount:'',
			};
		},
		methods:{
			inputAmount(e){
				let inuptval = e.detail.value;
				let val = APP._apputil().inputAmount(inuptval,2);
				//组件完全挂载之后执行该操作
				this.$nextTick(() => {
					this.dataAmount = val;
				});
			},
			bindFormSubmit(event){
			   let _this = this;
			   
			   let frmval = event.detail.value;
			   
			   if(frmval.amount.length < 1){
				   APP._apptool().showToastInfo('请输入大于1元金额！');
				   return;
			   }
			   
			   APP._post('接口', {
				old_password: frmval.amount
			   }, null, function(res) {
				//执行成功
				if (res.caCode === APP._appconfig().fwcode.successed) {
					APP._apptool().showToastInfo('操作成功！',null,null,function(res){
						uni.navigateBack({
							delta:1
						});
					});
				} else {
					APP._apptool().showToastInfo(res.caMsg);
				}
			   }, function(res) {
				//执行失败
			   }, function(res) {
				//执行完成
			   });
		   },
		}
	}
</script>

<style lang="scss">
.form{
	width: 100%;
	display: flex; display:-webkit-flex; flex-direction: column;
	font-size: 30rpx;
	.form-row{
		width: 100%; padding: 20rpx;
		display: flex; display:-webkit-flex; flex-direction: row; align-items: center;
		border-bottom: 1rpx solid #DDDDDD;
		.title{
			font-size: 30rpx;
		}
		input{
			margin-left: 20rpx; flex: 1;
		}
		text{
			width: 100rpx;
			color: #FF0000; text-align: center;
		}
	}
	.btn-row{
		border-bottom: none;
	}
}
</style>
